package fr.esiag.projet17.jdbc;

import java.sql.DriverManager;
import java.sql.SQLException;

/**
 * @author teddy
 *
 */
public class ConnectionOracle {

	private volatile static java.sql.Connection connection;
	/**
	 * URL de connection
	 */
	private static String url = "jdbc:oracle:thin@:localhost:1521:orcl";
	/**
	 * Nom du user
	 */
	private static String user = "root";
	/**
	 * Mot de passe du user
	 */
	private static String passwd = "password";

	/**
	 * Objet Connection
	 */

	public static java.sql.Connection getInstance() {
		if (connection == null) {
			synchronized (ConnectionOracle.class) {
				if (connection == null)
					try {
						Class.forName("oracle.jdbc.driver.OracleDriver");
						connection = DriverManager.getConnection(url, user,	passwd);
					} catch (ClassNotFoundException e) {
						e.printStackTrace();
						System.err.println(e.getMessage());
					} catch (SQLException e) {
						e.printStackTrace();
					} 
				}
			}

		return connection;
	}
}
